package com.topcoder.srm521;

public class MissingParentheses {

	public int countCorrections(String par) {
		int count = 0;
		int left = 0;
		
		for (char c : par.toCharArray()) {
			if (c == '(') {
				left++;
			}
			else {
				left--;
			}
			
			if (left < 0) {
				count++;
				left++;
			}
		}
		
		return count + left;
	}

}
